package coop.main.service;

import coop.main.domain.Maestro;
import coop.main.repository.MaestroRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class MaestroServiceImpl implements MaestroService {

	@Autowired
    MaestroRepository maestroRepository;

	public long countAllMaestroes() {
        return maestroRepository.count();
    }

	public void deleteMaestro(Maestro maestro) {
        maestroRepository.delete(maestro);
    }

	public Maestro findMaestro(Long id) {
        return maestroRepository.findOne(id);
    }

	public List<Maestro> findAllMaestroes() {
        return maestroRepository.findAll();
    }

	public List<Maestro> findMaestroEntries(int firstResult, int maxResults) {
        return maestroRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveMaestro(Maestro maestro) {
        maestroRepository.save(maestro);
    }

	public Maestro updateMaestro(Maestro maestro) {
        return maestroRepository.save(maestro);
    }
}
